﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CUREEntity;
using CUREBusinessLogicLayer;
using System.Data;
using CURE.Handler;


namespace CURE.SystemManagement
{
    public partial class DeptManagement : System.Web.UI.Page
    {
        #region 分页变量，与UI绑定
        private int numPerPage;
        /// <summary>
        /// 每页显示的条数


        /// </summary>
        public int NumPerPage
        {
            get
            {
                int temp = Convert.ToInt32(Request.Form["numPerPage"]);
                return temp == 0 ? 20 : temp;
            }
            set { numPerPage = value; }
        }

        private int pageNumShown = 10;
        /// <summary>
        /// 页数导航的个数


        /// </summary>
        public int PageNumShown
        {
            get { return pageNumShown; }
            set { pageNumShown = value; }
        }

        private int pageNum;
        /// <summary>
        /// 当前显示的页数


        /// </summary>
        public int PageNum
        {
            get
            {
                int temp = Convert.ToInt32(Request.Form["pageNum"]);
                return temp == 0 ? 1 : temp;
            }
            set { pageNum = value; }
        }

        private int totalCount;
        /// <summary>
        /// 总条数


        /// </summary>
        public int TotalCount
        {
            get { return totalCount; }
            set { totalCount = value; }
        }

        private string keywords;
        /// <summary>
        /// where语句，不加where与空格


        /// </summary>
        public string Keywords
        {
            get
            {
                string temp = Request.Form["keywords"];
                return temp;
            }
            set { keywords = value; }
        }



        private string orderField;
        /// <summary>
        /// 排序关键字


        /// </summary>
        public string OrderField
        {
            get
            {
                string temp = Request.Form["orderField"];
                return temp;
            }
            set { orderField = value; }
        }
        #endregion

        #region 变量
        private string dept_id;

        public string Dept_id
        {
            get { return dept_id; }
            set { dept_id = value; }
        }
        private string dept_name;

        public string Dept_name
        {
            get { return dept_name; }
            set { dept_name = value; }
        }
        #endregion
        protected void Page_Load(object sender, EventArgs e)
        {
            JudgeAuthority ja = new JudgeAuthority();
            if (ja.JudgeUserAuthorityByGroupId("SystemManagement/DeptManagement.aspx"))
            {

                dept_id = Request.Form["deptid"];
                dept_name = Request.Form["deptname"];
                GetDeptData();
            }
            else
            {
                Response.Write("<script language=javascript>top.location.href='../../Login.aspx';</script>");
                Response.End();
            }
        }

        DeptBll deptbll = new DeptBll();
        public void GetDeptData()
        {
            IDictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("dept_id", dept_id);
            dic.Add("dept_name", dept_name);
            int totalPageCount;
            DataSet ds = deptbll.GetDeptData(dic, PageNum, NumPerPage, out totalCount, out totalPageCount);
            if (ds != null)
            {
                RepeaterDept.DataSource = ds;
                RepeaterDept.DataBind();
            }

        }
    }
}